#ifndef _D3D_D3DDepthMapShader_
#define _D3D_D3DDepthMapShader_

#include <windows.h>
#include <d3dx9.h>

#include "..\..\common\types.h"
#include "..\..\common\arraylist.hpp"

#include "..\d3d.h"
#include "..\d3d_util.h"
#include "d3d_shader.h"
#include "..\..\common\string.h"

/**************************************
 *
 **************************************/
struct D3DDepthMapShader : public D3DShader
{
private:
	friend class CD3D9Device; 
	D3DDepthMapShader(CD3D9Device *pDevice); 
	
	HashTable<InstanceData, D3DRenderable*> m_MaskMeshHashInstances; 
	LPDIRECT3DVERTEXBUFFER9 mp_MaskInstanceVB; 
	unsigned int	mui_LastMaskInstanceCount; 
	
	D3DXHANDLE mp_Technique; 
	D3DXHANDLE mp_MaskTechnique; 
	bool mb_Locked; 

	HRESULT ConstructSubGroupInstanceBuffer(HashTable<InstanceData, D3DRenderable*>* pSubGroup, unsigned int* pLastInstanceCount, LPDIRECT3DVERTEXBUFFER9* pInstanceBuffer);
protected:
	HRESULT ConstructInstanceBuffer();
public:
	string GetType(); 

	static string Identifier(); 
	HRESULT Release(); 
	HRESULT Create(const string& szFilename); 
	HRESULT Reload(); 
	void RenderDepthMap(RenderTarget* pDepthBuffer, const ViewOrrientation* pView); 
	void AddRenderQue(D3DRenderable* pMesh, const Matrix4f& transform); 
	
	void RenderMeshes(const int flags = RENDER_DEFAULT); 
	//void FlushRenderList(void); 
	void PreExecute();
	void PostExecute(); 
}; 


#endif